import 'package:flutter/material.dart';
import 'package:flutter_smart_heating/ui/ui.dart';

class BasicStationItemView extends StatelessWidget {
  const BasicStationItemView({super.key, this.item, this.index});
  final dynamic item;
  final dynamic index;
  @override
  Widget build(BuildContext context) {
    bool isBlock = item['id'] == null;
    return UiOpen(
      url: item['url'] ?? '',
      child: UiPanel(
        height: 90,
        margin: EdgeInsets.only(
          top: index == 0 ? UiTheme.spacingX : 0,
          left: UiTheme.spacingX,
          right: UiTheme.spacingX,
        ),
        padding: const EdgeInsets.symmetric(horizontal: 15),
        child: Row(
          children: [
            Container(
              width: 14,
              height: 14,
              decoration: BoxDecoration(
                color: item['status'] == 1
                    ? Colors.blue
                    : Colors.grey.withOpacity(0.2),
                borderRadius: BorderRadius.circular(7),
              ),
            ),
            const SizedBox(width: UiTheme.spacingX),
            Expanded(
              child: Column(
                mainAxisSize: MainAxisSize.min,
                crossAxisAlignment: CrossAxisAlignment.start,
                children: [
                  isBlock
                      ? const UiBlock(height: 22)
                      : Text(
                          item['name'] ?? '',
                          overflow: TextOverflow.ellipsis,
                          style: const TextStyle(
                            fontSize: 18,
                            fontWeight: FontWeight.bold,
                          ),
                        ),
                  const SizedBox(height: 5),
                  isBlock
                      ? const UiBlock(height: 15, margin: 5, width: 200)
                      : Row(
                          children: [
                            const UiIcon(
                              UiIcons.company,
                              size: 17,
                            ),
                            const SizedBox(width: 5),
                            if (!isBlock)
                              Text(
                                '${item['company_name']}',
                              )
                          ],
                        )
                ],
              ),
            ),
            const SizedBox(width: 5),
            if (item['id'] != null)
              Icon(
                Icons.arrow_forward_ios,
                color: UiTheme.of(context).listCellArrowColor,
                size: 16,
              ),
          ],
        ),
      ),
    );
  }
}
